@echo off
echo ========================================
echo 检查后端服务状态
echo ========================================

echo.
echo 1. 检查Java进程...
tasklist | findstr java
if %errorlevel% neq 0 (
    echo 没有找到Java进程，后端服务未运行！
    pause
    exit /b 1
)

echo.
echo 2. 检查端口8080...
netstat -an | findstr :8080
if %errorlevel% neq 0 (
    echo 端口8080未监听，后端服务未运行！
    pause
    exit /b 1
)

echo.
echo 3. 测试基本接口...
echo 测试 /system/arrangement/test-image-endpoint...
curl -X GET "http://localhost:8080/system/arrangement/test-image-endpoint"

echo.
echo 4. 测试上传接口...
echo 测试 /system/arrangement/upload...
echo 这是一个测试文件 > test-backend.txt
curl -X POST -F "file=@test-backend.txt" http://localhost:8080/system/arrangement/upload

echo.
echo 5. 检查上传目录...
dir "D:\Lekang\le-kang-service\lekang-lkyl\src\main\resources\static\uploads"

echo.
echo 6. 测试图片获取接口...
for %%f in ("D:\Lekang\le-kang-service\lekang-lkyl\src\main\resources\static\uploads\*.txt") do (
    echo 测试文件: %%~nxf
    curl -I "http://localhost:8080/system/arrangement/image/%%~nxf"
    echo.
)

echo.
echo 检查完成！
echo 如果所有接口都返回200，说明后端服务正常运行
echo 如果图片获取接口返回404，说明接口路径有问题
pause
